﻿using System;
using System.Windows;

namespace NanoMvvm.Xaml
{
    /// <summary>
    /// A simple helper class to designate a ViewModel and View pair as a xaml resource.
    /// </summary>
    public sealed class WorkspaceViewDesignator
    {
        private Type viewModelType;
        private Type viewType;

        public Type ViewModelType
        {
            get { return viewModelType; }

            set
            {
                if (value == null) throw new ArgumentNullException("value");
                if (!typeof(WorkspaceViewModel).IsAssignableFrom(value))
                    throw new ArgumentException("Workspace Type must inherit from NanoMvvm.WorkspaceViewModel.");
                viewModelType = value;
            }
        }

        public Type ViewType
        {
            get { return viewType; }

            set
            {
                if (value != null && !typeof(Window).IsAssignableFrom(value))
                    throw new ArgumentException("View Type must inherit from System.Windows.Window.");
                viewType = value;
            }
        }
    }
}